#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-

# @Time    :2023/05/07 22:45:28
# @Author  :wakeblade (2390245#qq.com) 
# @version :8.1

"""
stock.py -- 获取股票数据的API
"""

from ..core import ApiProxy, _get, ResType

# 获取symbol的Tick数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_ticks(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的分钟级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_minute_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的5分钟级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_5min_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的15分钟级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_15min_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的30分钟级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_30min_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x分钟级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xmin_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的小时级历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_hour_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x小时历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xhour_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的日线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_day_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x日数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xday_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的周线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_week_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x周数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xweek_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的月线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_month_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x月数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xmonth_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的季线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_quarter_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x季数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xquarter_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的半年线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_half_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x半年数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xhalf_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的年线历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_annal_bars(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x年数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xannal_bars(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的Tick除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_ticks_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的分钟级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_minute_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的5分钟级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_5min_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的15分钟级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_15min_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的30分钟级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_30min_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x分钟级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xmin_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的小时级除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_hour_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x小时除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xhour_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的日线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_day_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x日除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xday_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的周线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_week_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x周除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xweek_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的月线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_month_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x月除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xmonth_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的季线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_quarter_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x季除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xquarter_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的半年线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_half_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x半年除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xhalf_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

# 获取symbol的年线除权历史数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_annal_bars_xr(api:ApiProxy, symbol:str, begin:int, end:int):
    pass

# 获取symbol的x年除权数据
@_get(needToken=True, resType=ResType.DATAFRAME)
def get_xannal_bars_xr(api:ApiProxy, symbol:str, x:int, begin:int, end:int):
    pass

if __name__ == "__main__":
    appKey = "wakeblade"
    appSecret = "Ay7WH7Vk4aU1I7Y4AQte9beBlQqLWzes"
    print(f"appKey: {appKey} | appSecret: {appSecret}")
    api = ApiProxy(appKey, appSecret, "http://127.0.0.1/api")
    res = api.login()
    # print(api.__dict__)
    df = get_xannal_bars_xr(api, symbol="600138.SSE", x=5)
    # res = pd.read_csv("http://127.0.0.1:21025/api/get_xannal_bars_xr?symbol=600138.SSE&x=5")
    # with open("test.parquet", mode="wb") as f:
    #     f.write(res)
    # df = pd.read_parquet("test.parquet")
    # df = pd.read_parquet(io.BytesIO(res))
    print(df)